package ru.alt22.visor.php.ui.decorators;

import org.eclipse.core.resources.IFolder;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ILightweightLabelDecorator;

import ru.alt22.visor.php.properties.Properties;
import ru.alt22.visor.php.ui.PDToolsUIPlugin;
import ru.alt22.visor.php.ui.PluginImages;

public class SourceFolder implements ILightweightLabelDecorator {
	
	private ImageDescriptor folderImage;

	public void decorate(Object element, IDecoration decoration) {
		if (element instanceof IFolder) {
			if (Properties.isSourceFolder((IFolder) element)) {
				decoration.addOverlay(folderImage(), IDecoration.TOP_RIGHT);
				return;
			}
		}
	}

	private ImageDescriptor folderImage() {
		if (folderImage == null) {
			folderImage = PDToolsUIPlugin.getImageDescriptor(PluginImages.IMAGE_PACKAGE_FOLDER_INFO);
		}
		return folderImage;
	}
	
	public void addListener(ILabelProviderListener listener) {
	}

	public boolean isLabelProperty(Object element, String property) {
		return false;
	}

	public void removeListener(ILabelProviderListener listener) {
	}

	public void dispose() {
		folderImage = null;
	}

}